#include "loadingdialog.h"
#include "ui_loadingdialog.h"

#include <QMovie>

LoadingDialog::LoadingDialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::LoadingDialog)
{
    ui->setupUi(this);

    // 设置窗口样式，去掉边框，置顶显示，并显示系统菜单按钮
    setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::WindowSystemMenuHint);
    // 设置窗口背景透明
    setAttribute(Qt::WA_TranslucentBackground);
    // 设置窗口尺寸为父窗口尺寸
    setFixedSize(parent->size());

    // 设置动画效果
    QMovie *movie = new QMovie(":/res/loading.gif");
    ui->loading_label->setMovie(movie);
    // 设置图片居中显示
    ui->loading_label->setAlignment(Qt::AlignCenter);
    movie->start();
}

LoadingDialog::~LoadingDialog()
{
    delete ui;
}
